#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include "DataHelper.h"
#include "taskcreator.h"
#include "howtouse.h"
#include "View.h"

#include "QTreeWidgetItem"
#include "QColorDialog"
#include "QRadioButton"
#include "QMap"
#include "QFileDialog"
#include "QMessageBox"


QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void on_selectTaskDB_clicked();
    void on_saveChanges_clicked();
    void on_howToUse_clicked();
    void on_create();
    void on_moveUp();
    void on_moveDown();
    void on_duplicate();
    void on_remove();
    void on_restore();

    void createTreeTaskItem (Task *task);
    void createTreeGroupItem(Group *group);  

    void showTasks();
    void showGroups();

    void on_editTasks_clicked();
    void on_editGroups_clicked();

    void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
    void on_userSelectColor(const QColor &color);

    void updateId(const QPoint *point);

    void getTaskFromChild (QString *name, int groupId, int timer, int times);
    void getGroupFromChild(QString *name, QColor *color);

    Task*  taskById        (int id);
    Task*  taskByName      (QString *name);
    Group* groupById       (int id);
    Group* groupByName     (QString *name);
    bool   isTaskNameExists(QString *name);

    Task * createTask (int id, int timer, QString *name, Group *group, bool status);
    Group* createGroup(int id, QString *name, QColor *color);

    QString currDateTime();

private:
    QWidget *mainWidget;    

    QRadioButton *editTasks;
    QRadioButton *editGroups;

    QMessageBox *msg = nullptr;
    QPushButton *no_b = nullptr;

    bool isTaskDbFileSelected = false;

    QString version = "0.05";

    QFileDialog dlg;
    QDir saveDir;

    QVector<Task*>  *tasks  = nullptr;
    QVector<Group*> *groups = nullptr;

    QVector<QString*> needToBackUp;

    QColorDialog colorSelector;

    View *treeWidget;
    TaskCreator taskCreator;
    HowToUse howToUse;
};
#endif // MAINWINDOW_H
